<template>
    <div>
      <!-- <h1>推荐</h1> -->
      <div class="content">
        <div class="title">
          <ul>
            <li v-for="item,index in tab" :key="item.name" @click="goSon(item)">
                <!-- 标题栏 -->
                <a :href="'#'+ index">  {{ item.name }}</a>
              <!-- 小信息栏 -->
            </li>
          </ul>
        </div>
          <div class="detail">
            <!-- {{ item.name }} -->
            <router-view></router-view>
          </div>
      </div>
      <div class="footer">
             <p class="p1">
              <img src="../../img/shop.png" alt="">
             </p>
             <p class="p2">￥0</p>
             <p class="p2">另需配送费4元</p>
             <p class="p2">20元起送</p>
      </div>
    </div>
  </template>
  
  <script>
  import axios from "axios";
  export default {
    data() {
      return {
        tab: [],
      };
    },
    created() {
      axios.get("http://localhost:3006/list").then((res) => {
        this.tab=res.data.goods;
        // console.log(res);
        // console.log(this.tab)
      });
      this.getData();
    },
    methods: {
      goSon(item) {
        this.$router.push({
          path: "/shangpin/son",
          query: {
            ...item,
            data:JSON.stringify(item)
            // item
          },
         
        });
      },
      async getData() {
        const data = await axios.get("http://localhost:3006/list");
        // this.tab=data.data.goods;

        // console.log(this.tab)
        // this.tab = [...data.goods];
        // console.log(data.goods);
      },
    },
  };
  </script>
  <style scoped>
  .content{
    width: 800px;
    margin: 0 auto;
    display: flex;
  }
  .title{
    width: 160px;
    height: 1000px;
    background-color: #f3f5f7;
    /* border: 1px solid red; */
  }
  .title ul{
    margin: 0;
    padding: 0;
  }
  .title ul li{
    position: relative;

    width: 160px;
    height: 108px;
    background-color: #f3f5f7;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    list-style: none;
    /* margin-bottom: 15px; */
    font-size: 24px;
    text-align: center;
  }
  .title  a{
    color: black;
    text-decoration: none;
  }
  .title ul li::after{
  content: "";
  display: block;
  width: 140px;
  height: 2px;
  position: absolute;
  bottom: 0;
 border-bottom: 1px solid #dadddf;
}

  ul li:hover {
    background-color:white;
  }
  .detail{
    flex: 1;
    height: 972px;
    overflow: scroll;
    /* border: 1px solid red; */
  }
  .footer{
    /* width: 800px; */
    height: 116px;
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: black;
    color: rgba(255, 255, 255,0.4);
    font-size: 30px;
    position: relative;
    padding-left: 160PX;
  }
  .footer .p1{
    width:100px ;
    height: 100px;
    border-radius: 50%;
    background-color: black;
    position: absolute;
    top: -50px;
    left: 36px;
  }
  .footer .p1 img{
    width:88px ;
    height: 88px;
    border-radius: 50%;
    margin: 6px 6px;

  }
  .footer .p2{
    height: 100px;
    line-height: 100px;
  }
  .footer .p2:hover{
    background-color: rgba(255, 255, 255, 0.4);
  }
  </style>
  